package com.seleniti.enpareja.web.desktop.client.ui.view;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Widget;
import com.seleniti.enpareja.controller.ui.view.UserSettingsView;
import com.seleniti.enpareja.controller.ui.view.UserSettingsView.Action;
import com.seleniti.enpareja.controller.ui.view.UserSettingsView.Event;
import com.seleniti.enpareja.controller.ui.view.UserSettingsView.Operation;
import com.seleniti.enpareja.controller.ui.view.UserSettingsView.Presenter;
import com.seleniti.enpareja.controller.ui.view.UserSettingsViewPresenter;
import com.seleniti.enpareja.controller.ui.widget.UserForm;
import com.seleniti.enpareja.web.desktop.client.ui.widget.UserFormWidget;

public class SettingsViewWidget extends EnParejaBaseView<Event, Operation, Action, Presenter> implements UserSettingsView {

	private static TemplateUiBinder uiBinder = GWT.create(TemplateUiBinder.class);

	interface TemplateUiBinder extends UiBinder<Widget, SettingsViewWidget> {
	}

	@UiField
	UserFormWidget userForm;
	
	private boolean showDownloadAppWhenPassword;

	public SettingsViewWidget() {
		this.presenter = new UserSettingsViewPresenter(this, eventbus, operationManager, actionController);
		initWidget(uiBinder.createAndBindUi(this));
	}

	public SettingsViewWidget(boolean passwordChangeEnabled) {
		this();
		this.userForm.setPasswordChangeEnabled(passwordChangeEnabled);
	}

	@Override
	public UserForm userForm() {
		return this.userForm;
	}

	@Override
	public void setPasswordChangeEnabled(boolean passwordChangeEnabled) {
		this.userForm.setPasswordChangeEnabled(passwordChangeEnabled);
	}

	@Override
	public boolean isPasswordChangeEnabled() {
		return this.userForm.isPasswordChangeEnabled();
	}

	@Override
	public void setShowDownloadAppWhenPassword(boolean showDownloadAppWhenPassword) {
		this.showDownloadAppWhenPassword = showDownloadAppWhenPassword;
	}

	@Override
	public boolean isShowDownloadAppWhenPassword() {
		return this.showDownloadAppWhenPassword;
	}

}
